package com.sinven.controller;

import com.sinven.common.Pager;
import com.sinven.pojo.Article;
import com.sinven.pojo.SinglePage;
import com.sinven.pojo.Student;
import com.sinven.service.ArticleService;
import com.sinven.service.CategoryService;
import com.sinven.service.SinglePageService;
import com.sinven.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping("recruit")
public class RecruitController {

    @Autowired
    private StudentService studentService;
    @Autowired
    private SinglePageService pageService;
    @Autowired
    private ArticleService articleService;
    @Autowired
    private CategoryService categoryService;
    @RequestMapping("students.html")
    public String showStudent(Model model, @RequestParam(value = "page",defaultValue = "1")Long page){
        Pager<Student> pager = studentService.queryStudents(page);
        model.addAttribute("pager",pager);
        return "recruit/students";
    }

    @RequestMapping("apply.html")
    public String apply(){
        return "recruit/apply";
    }

    @RequestMapping("manual.html")
    public String manual(Model model){
        SinglePage manual = pageService.queryPage("manual");
        model.addAttribute("page",manual);
        return "singlepage";
    }
    @RequestMapping("guide.html")
    public String guide(Model model,@RequestParam(value = "page",defaultValue = "1")Long page){
        Pager<Article> pager = articleService.queryArticles("guide", page);
        model.addAttribute("pager",pager);
        return "recruit/guide";
    }
}
